# Maintainer: Bjoern Lemke <lemke@lemke-it.com>

_realname=dragon
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.5.5
pkgrel=1
pkgdesc="Dragon parser generator (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.lemke-it.com/'
msys2_references=(
  'archlinux: '
  'aur: '
  'gentoo: '
  'cygwin: '
)
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-lfcbase"
         "${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://www.lemke-it.com/${_realname}-${pkgver}.tar.gz")
sha256sums=('b5f5d601e61724fd1716ee50473cc5833ab23042476991abb084a9d0f9dfdd6d')

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "build-${MSYSTEM}"
  make check
}

package() {
  cd "build-${MSYSTEM}"
  make install DESTDIR="${pkgdir}"
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
